package com.fire.control.system.module.warning.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.fire.control.system.dto.MsgPushSetDTO;
import com.fire.control.system.entity.MessagePushSet;

public interface MessagePushSetMapper {

	
	@Select("select * from t_warning_message_set where company_id=#{compId} and warning_type=#{warningType}")
	public MessagePushSet getMessagePushSet(@Param("compId")String compId,@Param("warningType")String warningType);
	
	
	/**
	* @Title: getMessageRoles
	* @Description: TODO(报警推送角色列表)
	* @author wanbo
	* @date  2017年6月20日 上午10:34:30
	* @param msgSetId
	* @return
	*/
	@Select("select role_id from t_warning_message_role where warning_msg_id=#{msgSetId}")
	public List<Object> getMessageRoles(@Param("msgSetId")String msgSetId);
	
	/**
	 * @author: xiechengguang 
	 * @Title: updateMessagePushSet   
	 * @Description: 修改报警推送设置  
	 */
	public int updateMessagePushSet(MessagePushSet messagePushSet);
	
	/**
	 * @author: xiechengguang 
	 * @Title: saveMsgPushSetAndRoleRelation   
	 * @Description: 保存报警推送--角色关系  
	 */
	@Insert("insert into t_warning_message_role(warning_msg_id,role_id) values(#{id},#{roleId})")
	public int saveMsgPushSetAndRoleRelation(@Param("id") String id, @Param("roleId") String roleId);
	
	/**
	 * @author: xiechengguang 
	 * @Title: saveMsgPushSetAndRoleRelation   
	 * @Description: 删除报警推送--角色关系  
	 */
	@Delete("delete from t_warning_message_role where warning_msg_id = #{id} and role_id = #{roleId}")
	public int deleteMsgPushSetAndRoleRelation(@Param("id") String id, @Param("roleId") String roleId);
	
	/**
	 * @author: xiechengguang 
	 * @Title: deleteMessagePushSet   
	 * @Description: 删除报警推送（软删除）  
	 */
	@Update("update t_warning_message_set m set m.status = false where m.id = #{id}")
	public int deleteMessagePushSet(String id);
	
	/**
	 * @author: xiechengguang 
	 * @Title: getMsgPushSetList   
	 * @Description: 获取本企业下的报警推送列表  
	 */
	public List<MsgPushSetDTO> getMsgPushSetList(String companyId);
	
	/**
	 * @author: xiechengguang 
	 * @Title: getById   
	 * @Description: 根据id获取报警推送信息  
	 */
	public MsgPushSetDTO getById(@Param("id") String id);
	
	@Select("SELECT * FROM t_warning_message_set WHERE id = #{id} ")
	public MessagePushSet findById(String id);
	
}
